/* Copyright (c) 2009-2010, Sean A.O. Harney <sharney3@gmail.com> */

#ifndef FUZZER_BUILTIN_FUNCS_H
#define FUZZER_BUILTIN_FUNCS_H

typedef EXPR_P(*BUILTIN_FUNC_VOID_P) (void);
typedef EXPR_P(*BUILTIN_FUNC_UNARY_P) (EXPR_P);
typedef EXPR_P(*BUILTIN_FUNC_BINARY_P) (EXPR_P, EXPR_P);
typedef EXPR_P(*BUILTIN_FUNC_TRINARY_P) (EXPR_P, EXPR_P, EXPR_P);

typedef struct st_builtin_func *BUILTIN_FUNC_P;

struct st_builtin_func {
    int arity;
    union {
	BUILTIN_FUNC_VOID_P funcp_void;
	BUILTIN_FUNC_UNARY_P funcp_unary;
	BUILTIN_FUNC_BINARY_P funcp_binary;
	BUILTIN_FUNC_TRINARY_P funcp_trinary;
    } funcp;
};


/* prototypes */
bool builtin_funcs_init(void);
void builtin_funcs_add_void(char *funcname, BUILTIN_FUNC_VOID_P func_ptr);
void builtin_funcs_add_unary(char *funcname, BUILTIN_FUNC_UNARY_P func_ptr);
void builtin_funcs_add_binary(char *funcname,
			     BUILTIN_FUNC_BINARY_P func_ptr);
void builtin_funcs_add_trinary(char *funcname,
			      BUILTIN_FUNC_TRINARY_P func_ptr);
EXPR_P builtin_funcs_invoke(BUILTIN_FUNC_P builtin_func, EXPR_P args[]);



EXPR_P builtin_func_hd(EXPR_P list);
EXPR_P builtin_func_tl(EXPR_P list);
EXPR_P builtin_func_sleep(EXPR_P expr);
EXPR_P builtin_func_eval(EXPR_P expr);
EXPR_P builtin_func_open(EXPR_P expr0, EXPR_P expr1);
EXPR_P builtin_func_flush(EXPR_P expr);
EXPR_P builtin_func_close(EXPR_P expr);
EXPR_P builtin_func_write(EXPR_P expr_fd, EXPR_P expr_data);
EXPR_P builtin_func_read(EXPR_P expr_fd, EXPR_P expr_n);

#endif				/* FUZZER_BUILTIN_FUNCS_H */
